#绝对布局  窗口指定每一个控件显示的坐标和大小来布局的
import sys
from  PyQt5.QtWidgets import *
class Example(QWidget):
    def __init__(self,parent=None):
        super(Example,self).__init__(parent)
        self.initUI()
    def initUI(self):
        grid=QGridLayout()
        self.setLayout(grid)
        items=['cls','back','','close',
               '7','8','9','/',
               '4','5','6','*',
               '1','2','3','-',
               '0','.','=','+'
               ]
        positions=[(i,j) for i in range(5) for j in  range(4)]

        for postion,name in zip(positions,items):
            if name=='':
                continue
            button=QPushButton(name)
            grid.addWidget(button,*postion)
        self.move(300,150)
        self.setWindowTitle("网格布局")
if __name__ == '__main__':
    app=QApplication(sys.argv)
    demo=Example()
    demo.show()
    sys.exit(app.exec_())
